<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title th:text="${errorTitle} + ' - AI文档助手'">错误 - AI文档助手</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 20px;
        }
        
        .error-container {
            max-width: 600px;
            background: white;
            border-radius: 15px;
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
            padding: 40px;
            text-align: center;
        }
        
        .error-icon {
            font-size: 4em;
            margin-bottom: 20px;
            color: #dc3545;
        }
        
        .error-title {
            font-size: 2em;
            color: #343a40;
            margin-bottom: 15px;
            font-weight: bold;
        }
        
        .error-message {
            font-size: 1.1em;
            color: #6c757d;
            margin-bottom: 20px;
            line-height: 1.6;
        }
        
        .error-code {
            background: #f8f9fa;
            border: 1px solid #dee2e6;
            border-radius: 8px;
            padding: 15px;
            margin-bottom: 30px;
            font-family: 'Courier New', monospace;
            color: #495057;
        }
        
        .error-actions {
            display: flex;
            gap: 15px;
            justify-content: center;
            flex-wrap: wrap;
        }
        
        .btn {
            padding: 12px 24px;
            border: none;
            border-radius: 8px;
            text-decoration: none;
            font-size: 1em;
            cursor: pointer;
            transition: all 0.3s;
            display: inline-block;
        }
        
        .btn-primary {
            background: #007bff;
            color: white;
        }
        
        .btn-primary:hover {
            background: #0056b3;
            transform: translateY(-2px);
        }
        
        .btn-secondary {
            background: #6c757d;
            color: white;
        }
        
        .btn-secondary:hover {
            background: #545b62;
            transform: translateY(-2px);
        }
        
        .error-details {
            margin-top: 30px;
            padding-top: 20px;
            border-top: 1px solid #dee2e6;
            text-align: left;
        }
        
        .error-details h4 {
            color: #495057;
            margin-bottom: 10px;
        }
        
        .error-details pre {
            background: #f8f9fa;
            border: 1px solid #dee2e6;
            border-radius: 4px;
            padding: 10px;
            font-size: 0.9em;
            overflow-x: auto;
            white-space: pre-wrap;
            word-wrap: break-word;
        }
        
        @media (max-width: 768px) {
            .error-container {
                padding: 30px 20px;
            }
            
            .error-title {
                font-size: 1.5em;
            }
            
            .error-actions {
                flex-direction: column;
                align-items: center;
            }
            
            .btn {
                width: 100%;
                max-width: 200px;
            }
        }
    </style>
</head>
<body>
    <div class="error-container">
        <div class="error-icon">⚠️</div>
        <h1 class="error-title" th:text="${errorTitle}">发生错误</h1>
        <p class="error-message" th:text="${errorMessage}">系统遇到了一个错误，请稍后再试。</p>
        
        <div class="error-code" th:if="${statusCode}">
            <strong>错误代码：</strong> <span th:text="${statusCode}">未知</span>
        </div>
        
        <div class="error-actions">
            <a href="/" class="btn btn-primary">🏠 返回首页</a>
            <button onclick="history.back()" class="btn btn-secondary">⬅️ 返回上页</button>
            <button onclick="location.reload()" class="btn btn-secondary">🔄 刷新页面</button>
        </div>
        
        <!-- 开发环境下显示详细错误信息 -->
        <div class="error-details" th:if="${exception}">
            <h4>详细错误信息：</h4>
            <pre th:text="${exception}"></pre>
        </div>
    </div>
    
    <script>
        // 自动刷新功能（可选）
        setTimeout(function() {
            const refreshBtn = document.querySelector('.btn-secondary:last-child');
            if (refreshBtn) {
                refreshBtn.style.background = '#28a745';
                refreshBtn.textContent = '🔄 自动刷新中...';
            }
        }, 10000);
    </script>
</body>
</html>